/*package com.hansming.bss.modules.sfc.web.front;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.activiti.engine.impl.util.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hansming.bss.common.utils.RegisterCheck;
import com.hansming.bss.common.utils.SendMailUtil;
import com.hansming.bss.common.utils.ValidateCodeUtil;			
import com.hansming.bss.common.web.BaseController;

import com.hansming.bss.modules.sfc.entity.Customer;
import com.hansming.bss.modules.sfc.service.CustomerService;

*//**
 * 前端用户相关 Controller
 * @author Hansming
 * @version 2017-10-10
 *//*
@Controller
@RequestMapping(value = "${frontAdminPath}/cus")
public class FrontCustomerController extends BaseController{
	
	@Autowired
	private CustomerService customerService;
	
	
	//获得图形验证码
	@RequestMapping(value = "getpiccode")
	public void getcode(HttpServletRequest request, HttpServletResponse response)throws IOException {
		response.setContentType("image/jpeg");
		response.setHeader("Pragma", "No-cache");
		response.setHeader("Cache-Control", "no-cache");
		response.setDateHeader("Expire", 0);
		ValidateCodeUtil randomValidateCode = new ValidateCodeUtil();
	     try {
	         randomValidateCode.getRandcode(request, response);
	     } catch (Exception e) {
	         e.printStackTrace();
	     } 		
	}
	
	
	//手机或邮箱登录
	@RequestMapping(value = "/login")
	public void cusLogin(String code,String password,String mcode,HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException {
		response.setCharacterEncoding("UTF-8");
        response.setHeader("Cache-Control", "no-cache");
        PrintWriter out = response.getWriter();
        JSONObject jsonObject = new JSONObject();
		HttpSession session = request.getSession();
		String resCode = "1";							//返回前台的消息状态
		String message = "";							//返回前台的消息
		JSONObject data = new JSONObject();				//返回的具体信息
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
		if(RegisterCheck.emailFormat(code)){		
			if(mcode.equalsIgnoreCase((String)session.getAttribute("RANDOMVALIDATECODEKEY"))){
				Customer customer = customerService.findCustomerByEmail(code,password);
				if(customer != null){
					customer.setLogintime(df.parse(df.format(new Date())));
					session.setAttribute("cus", customer);
					message = "登录成功";
				}else{
					resCode = "0"; 
					message = "登录失败，密码或验证码错误";
				}
			}else{
				resCode = "0";
				message = "登录失败，密码或验证码错误";
			}
		}else{
			if(mcode.equalsIgnoreCase((String)session.getAttribute("RANDOMVALIDATECODEKEY"))){
				Customer customer = customerService.findCustomerByPhone(code,password);
				if(customer != null){
					session.setAttribute("cus", customer);				
				}else{
					resCode = "0"; 
				}
			}else{
				resCode = "0"; 			
			}		
		}
		jsonObject.put("resCode", resCode);
		jsonObject.put("message", message);
		jsonObject.put("data", data);
		out.print(jsonObject.toString());
	    out.flush();
	    out.close();
	}
	
	//验证邮箱或者手机是否呗注册
	public void checkusername(String code,HttpServletRequest request, HttpServletResponse response) throws IOException{
		response.setCharacterEncoding("UTF-8");
        response.setHeader("Cache-Control", "no-cache");
        PrintWriter out = response.getWriter();
        JSONObject jsonObject = new JSONObject();
		String resCode = "1";							//返回前台的消息状态
		String message = "注册成功";							//返回前台的消息
		JSONObject data = new JSONObject();				//返回的具体信息
        if(RegisterCheck.emailFormat(code)){		
			Customer customer = customerService.checkEmail(code);
			if(customer == null){
				resCode = "0";
				message = "邮箱已注册";
			}
        }else{	
			Customer customer = customerService.checkPhone(code);
			if(customer == null){
				resCode = "0";
				message = "手机号码已注册";
			}
				
        }
		jsonObject.put("resCode", resCode);
		jsonObject.put("message", message);
		jsonObject.put("data", data);
		out.print(jsonObject.toString());
	    out.flush();
	    out.close();
	}
	
	
	//邮箱注册
	@RequestMapping(value = "/register")
	public void cusRegister(String email,String password,String mcode,HttpServletRequest request, HttpServletResponse response) throws IOException{
		response.setCharacterEncoding("UTF-8");
        response.setHeader("Cache-Control", "no-cache");
        PrintWriter out = response.getWriter();
        JSONObject jsonObject = new JSONObject();
		String resCode = "1";							//返回前台的消息状态
		String message = "";							//返回前台的消息
		JSONObject data = new JSONObject();				//返回的具体信息
		HttpSession session = request.getSession();
		Customer customer  = new Customer();
		if(mcode.equalsIgnoreCase((String)session.getAttribute("RANDOMVALIDATECODEKEY"))){
			customer.setEmail(email);
			customer.setPassword(password);
			customerService.save(customer);
			Customer cus = customerService.findCustomerByEmail(email, password);
			String subject = "搜房车帐户激活邮件";//发送邮件主题
			String contents = "<p>您好，感谢您在搜房车注册帐户！激活帐户需要点击下面的链接跳转至激活成功页面：</p>"
							+"<p><a>"+adminPath+"/cus/activate?id="+cus.getId()+"</a></p>"
							+"<p>--</p>"
							+"<p>搜房车搜房网</p>";//发送的邮件信息内容
			SendMailUtil.sendCommonMail(email, subject, contents);
			message = "邮件发送成功";
		}else{
			resCode = "0";
			message = "验证码错误";
		}
		jsonObject.put("resCode", resCode);
		jsonObject.put("message", message);
		jsonObject.put("data", data);
		out.print(jsonObject.toString());
		out.flush();
		out.close();
	}
	
	//激活帐号跳转页面
	@RequestMapping(value="/activate")
	public String activate(String id){
		customerService.activate(id);	
		return "";
	}

	
	
}
*/